home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Toolkit;
- import java.awt.Window;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JComponent;
- import javax.swing.JDialog;
- import javax.swing.JLabel;
- import javax.swing.JTextArea;
- import javax.swing.border.EmptyBorder;
- import javax.swing.text.JTextComponent;
-
- public class UpdateDialog extends JDialog implements ActionListener {
- protected Container main = new Container();
- protected JButton download;
- protected JButton cancel;
- protected boolean channelUpdate = false;
- private NewsMac theParent;
-
- public UpdateDialog(boolean channel, NewsMac parent, String version, String descriptionText) {
- super(parent, "", true);
- this.theParent = parent;
- ((Dialog)this).setResizable(false);
- this.channelUpdate = channel;
- Toolkit theKit = ((Window)this).getToolkit();
- int width = 420;
- int xPos = (int)(new Dimension(theKit.getScreenSize())).getWidth() / 2 - width / 2;
- ((Component)this).setBounds(xPos, 160, width, 150);
- JLabel logoIcon = new JLabel(new ImageIcon("newsmac.app/contents/resources/logo-icon.gif"));
- ((Component)logoIcon).setBounds(24, 16, 64, 64);
- JLabel title = AquaUtil.aquaLargeBoldLabel(104, 15, version, 2);
- JTextArea description = new JTextArea();
- ((JComponent)description).setOpaque(false);
- ((JTextComponent)description).setEditable(false);
- description.setLineWrap(true);
- description.setWrapStyleWord(true);
- ((JTextComponent)description).setText(descriptionText);
- ((JComponent)description).setBorder(new EmptyBorder(0, 0, 0, 0));
- description.setFont(AquaUtil.SMALL_SYSTEM);
- ((Component)description).setBounds(104, 41, 284, 40);
- if (this.channelUpdate) {
- this.download = AquaUtil.aquaButton(306, 90, "Yes", true, false);
- ((JDialog)this).getRootPane().setDefaultButton(this.download);
- this.download.addActionListener(this);
- this.cancel = AquaUtil.aquaButton(199, 90, "No", false, false);
- this.cancel.addActionListener(this);
- } else {
- this.download = AquaUtil.aquaButton(306, 90, "Download", true, false);
- ((JDialog)this).getRootPane().setDefaultButton(this.download);
- this.download.addActionListener(this);
- this.cancel = AquaUtil.aquaButton(199, 90, "Cancel", false, false);
- this.cancel.addActionListener(this);
- }
-
- this.main.add(logoIcon);
- this.main.add(title);
- this.main.add(description);
- this.main.add(this.download);
- this.main.add(this.cancel);
- ((JDialog)this).getContentPane().add(this.main);
- }
-
- public void paint(Graphics g) {
- super.paint(g);
- }
-
- public void actionPerformed(ActionEvent newEvent) {
- String buttonString = newEvent.getActionCommand();
- if (buttonString.equals("Download")) {
- try {
- NewsMacUtil.openURL("http://users.aber.ac.uk/rlp9/newsmac");
- } catch (Exception var5) {
- System.out.println("UpdateDialog: Open URL failed!");
- }
-
- ((Component)this).setVisible(false);
- }
-
- if (buttonString.equals("Yes")) {
- ((Component)this).setVisible(false);
-
- try {
- this.theParent.theEngine.loadAllChannels(true);
- this.theParent.theEngine.loadAllChannels(false);
- this.theParent.theEngine.applyChannelSettings();
- } catch (Exception var4) {
- System.out.println("UpdateDialog: Error reloading channels!+\t\n" + var4);
- }
- }
-
- if (buttonString.equals("Cancel") || buttonString.equals("No")) {
- ((Component)this).setVisible(false);
- }
-
- }
- }
-